home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / misc / dial.lha / dialengine.s < prev   
Text File  |  1992-09-02  |  4KB  |  200 lines

  1. ; This source dials a number, it can do either DTMF or CCITT5. It has built
  2. ; in letter recognition. Ie ABC -> 1, DEF -> 2 which can be switched off.
  3. ; It is also variable speed. Feel free to use in your programmes.
  4. ;
  5. ; NB: This isnt the source of the programme dial, just the routine which
  6. ; dials numbers. Dial is merely a frontend to this:
  7.  
  8.  
  9.         include "hardware/custom.i"
  10.  
  11. DialDTMF                                            ;dial DTMF,
  12.         movem.l    d1/d4-d7/a3-a5,-(sp)                ;a0=number in ascii            
  13.         lea        DTMF,a1                            ;chr(0) to end        
  14.         bra        Start
  15.  
  16. DialCCITT5                                            ;dial CCITT5,
  17.         movem.l    d1/d4-d7/a3-a5,-(sp)                ;a0=number in ascii
  18.         lea        CCITT5,a1                            ;chr(0) to end
  19.         
  20. Start    move.l    a0,a4
  21.         move.l    a1,a5
  22.         moveq    #SnSize,d0
  23.         moveq    #2,d1                                ;MEMF_CHIP
  24.         CALLEXEC AllocMem
  25.         move.l    d0,a0
  26.         move.l    #SnWaveS,a1
  27.         moveq    #SnSize-1,d1
  28.  
  29. CopyBf    move.b    (a1)+,(a0)+
  30.         dbf        d1,CopyBf
  31.  
  32.         move.l    a5,a1
  33.         move.l    a4,a0
  34.  
  35.         clr.l    d2
  36.         move.b    Speed,d2
  37.  
  38. NextTone
  39.         clr.l    d1
  40.         move.b    (a0)+,d1                            
  41.         cmp.b    #"*",d1
  42.         beq        Special
  43.         cmp.b    #"#",d1
  44.         beq        Special
  45.  
  46.         cmp.b    #"0",d1
  47.         blt        SkipNote
  48.         cmp.b    #"9",d1
  49.         bgt        NotDigit
  50.  
  51.         sub.b    #"0",d1
  52. DoneConv
  53.         lsl        #2,d1                                ;*4
  54.         move.w    0(a1,d1.w),d4                        ;Lookup table in words
  55.         move.w    2(a1,d1.w),d5                        ;get period of both tones
  56.         bsr        SoundTone
  57.         bra        Pause
  58. SkipNote
  59.         tst.b    (a0)
  60.         bne        NextTone
  61.  
  62.         move.l    d0,a1
  63.         moveq    #SnSize,d0
  64.         CALLEXEC FreeMem
  65.  
  66.         movem.l    (sp)+,d1/d4-d7/a3-a5
  67.         rts
  68.  
  69. Special    moveq.w    #10,d1                                ;* & #
  70.         cmpi.b    #"#",d1                                ;(does anyone want the
  71.         bne        NoAdN                                ;a,b,c or d tones?)
  72.         addq.w    #1,d1
  73. NoAdN    bra        DoneConv
  74.  
  75. NotDigit                                            ;Handles a-y
  76.         tst.b    Letter                                ;-nl -ignore letters
  77.         bne        SkipNote
  78.         
  79.         cmp.b    #"Q",d1                                ;Q & Z = 1
  80.         beq        DoLQZ
  81.         cmp.b    #"Z",d1
  82.         beq        DoLQZ        
  83.         bgt        SmallCase
  84.         cmp.b    #"A",d1                                ;=> 1-9
  85.         blt        SkipNote
  86.         cmp.b    #"Q",d1
  87.         blt        NoDif
  88.         subq.b    #1,d1
  89. NoDif    sub.b    #59,d1
  90.         divu    #3,d1
  91.         bra        DoneConv
  92. DoLQZ    move.l    #1,d1
  93.         bra        DoneConv
  94.  
  95. SmallCase
  96.         cmp.b    #"z",d1
  97.         beq        DoLQZ                                ;Q and Z come on the 
  98.         bgt        SkipNote
  99.         cmp.b    #"q",d1                                ;Number 1 button 
  100.         beq        DoLQZ                                ;sometimes
  101.         cmp.b    #"a",d1
  102.         blt        SkipNote
  103.         cmp.b    #"q",d1
  104.         blt        NoDifS
  105.         subq.b    #1,d1
  106. NoDifS    sub.b    #91,d1
  107.         divu    #3,d1
  108.         bra        DoneConv
  109.  
  110. SoundTone
  111.         lea        $dff000,a5
  112.         lea        aud1(a5),a3                            ;Right channel only
  113.         lea        aud2(a5),a4                            ;N.B Don't be clever
  114.         move.w    #$000f,dmacon(a5)                    ;and use stereo it 
  115.         move.l    d0,(a3)                                ;doesn't work then.
  116.         move.l    d0,(a4)
  117.         move.w    #SnSize/2,ac_len(a3)
  118.         move.w    #SnSize/2,ac_len(a4)
  119.         move.w    #64,ac_vol(a3)
  120.         move.w    #64,ac_vol(a4)
  121.         move.w    d4,ac_per(a3)
  122.         move.w    d5,ac_per(a4)
  123.         move.w    #$00ff,adkcon(a5)
  124.         move.w    #$8206,dmacon(a5)
  125.  
  126. timedelay
  127.         bsr        GetTime
  128.         move.l    d7,d6
  129. Cont    bsr        GetTime
  130.         sub.l    d6,d7
  131.         cmp.l    d2,d7
  132.         bgt        StopNote        
  133.         bra        Cont
  134.  
  135. StopNote
  136.         move.w    #$0006,dmacon(a5)
  137.         rts
  138.  
  139. Pause    bsr        GetTime
  140.         move.l    d7,d6
  141. Cont2    bsr        GetTime
  142.         sub.l    d6,d7
  143.         cmpi.l    #2,d7
  144.         bgt        SkipNote
  145.         bra        Cont2
  146.  
  147. GetTime    clr.l    d7                                    ;Stuff the timer.device
  148.         move.b    $bfea01,d7                            ;we programme direct
  149.         lsl.l    #4,d7                                ;via PIA
  150.         lsl.l    #4,d7
  151.         move.b    $bfe901,d7
  152.         lsl.l    #4,d7
  153.         lsl.l    #4,d7
  154.         move.b    $bfe801,d7
  155.         rts
  156.  
  157.         even
  158. DTMF    dc.w    238,166                            ;0
  159.         dc.w    319,186                            ;1
  160.         dc.w    319,166                            ;2
  161.         dc.w    319,151                            ;3
  162.         dc.w    290,184                            ;4
  163.         dc.w    290,166                            ;5
  164.         dc.w    290,151                            ;6
  165.         dc.w    263,184                            ;7
  166.         dc.w    263,166                            ;8
  167.         dc.w    263,151                            ;9
  168.         dc.w    238,184                            ;* 
  169.         dc.w    238,151                            ;# 
  170.         
  171. CCITT5    dc.w    128,120                            ;0
  172.         dc.w    162,149                            ;1
  173.         dc.w    162,138                            ;2
  174.         dc.w    149,138                            ;3
  175.         dc.w    162,128                            ;4
  176.         dc.w    149,128                            ;5
  177.         dc.w    138,128                            ;6
  178.         dc.w    162,120                            ;7
  179.         dc.w    149,120                            ;8
  180.         dc.w    138,120                            ;9
  181.         dc.w    138,112                            ;* 
  182.         dc.w    128,112                            ;# 
  183.  
  184. Speed    dc.b    5                                ;speed of dial
  185. Letter    dc.b    0                                ;0 = use letter recognitiion
  186.  
  187.         even
  188. SnWaveS
  189.         dc.b    0,49
  190.         dc.b    90,117
  191.         dc.b    127,117
  192.         dc.b    90,49
  193.         dc.b    0,-49
  194.         dc.b    -90,-117
  195.         dc.b    -127,-117
  196.         dc.b    -90,-49
  197. SnWaveE    
  198. SnSize    EQU    SnWaveE-SnWaveS
  199.  
  200.